import ctypes
import tkinter as tk

AWARE_DPI = True


def scale_factor():
    return ctypes.windll.shcore.GetScaleFactorForDevice(0)


def scale_ratio():
    if AWARE_DPI:
        return scale_factor() / 100
    else:
        return 1.0


def high_dpi_adapt_windows(root: tk.Tk):
    if AWARE_DPI:
        ctypes.windll.shcore.SetProcessDpiAwareness(2)
        root.tk.call("tk", "scaling", scale_factor() / 75)
